> ## Documentation Index
> Fetch the complete documentation index at: https://sequence-0fb8d9e6-api_docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Unreal 通貨スワップ

> Sequenceインフラストラクチャスタックを用いたweb3ゲーム向けUnreal SDK概要のドキュメントです。

SequenceのSmart Swap APIを使えば、特定チェーン上で異なるERC20やネイティブトークン間のスワップが簡単に行えます。

ご利用のトークンペアが、UniSwapなどの対応取引所で十分な流動性を確保していることをご確認ください。
[UniSwapで流動性を追加する方法については、こちらのガイドをご覧ください。](https://support.uniswap.org/hc/en-us/articles/7423194619661-How-to-add-liquidity-to-Uniswap-v3)

## スワップ価格の取得

指定したトークンペアのスワップ価格を取得します。

<Tabs>
  <Tab title="ブループリント">
    <Frame>
      <img src="https://mintcdn.com/sequence-0fb8d9e6-api_docs/auazpVRK2iFuGS6h/images/unreal/get_swap_price.png?fit=max&auto=format&n=auazpVRK2iFuGS6h&q=85&s=4a7255f18d94e2bb19beb5de7724d264" width="2074" height="1104" data-path="images/unreal/get_swap_price.png" />
    </Frame>
  </Tab>

  <Tab title="C++">
    ```cpp theme={null}
    const TSuccessCallback<FSeqSwapPrice> OnApiSuccess = [this, OnSuccess](const FSeqSwapPrice& Response) { };
    const FFailureCallback OnApiFailure = [this, OnFailure](const FSequenceError& Error) { };

    USequencePay* Pay = NewObject<USequencePay>();
    Pay->GetSwapPrice(SequenceSdk::GetChainId(), WalletAddress, SellCurrency, BuyCurrency, BuyAmount, OnApiSuccess, OnApiFailure);
    ```
  </Tab>
</Tabs>

## スワップ価格の取得

ユーザーが受け取りたいトークンのスワップ価格を取得します。

<Tabs>
  <Tab title="ブループリント">
    <Frame>
      <img src="https://mintcdn.com/sequence-0fb8d9e6-api_docs/auazpVRK2iFuGS6h/images/unreal/get_swap_prices.png?fit=max&auto=format&n=auazpVRK2iFuGS6h&q=85&s=029efb7241bb1d1c86d7c67dd60b133f" width="2074" height="1104" data-path="images/unreal/get_swap_prices.png" />
    </Frame>
  </Tab>

  <Tab title="C++">
    ```cpp theme={null}
    const TSuccessCallback<TArray<FSeqSwapPrice>> OnApiSuccess = [this, OnSuccess](const TArray<FSeqSwapPrice>& Response) { };
    const FFailureCallback OnApiFailure = [this, OnFailure](const FSequenceError& Error) { };

    USequencePay* Pay = NewObject<USequencePay>();
    Pay->GetSwapPrices(SequenceSdk::GetChainId(), WalletAddress, BuyCurrency, BuyAmount, OnApiSuccess, OnApiFailure);
    ```
  </Tab>
</Tabs>

## スワップ見積もりの取得

スワップ価格を確認した後、取引を構築するために必要な承認データとトランザクションデータを取得します。
`Sell Amount` または `Buy Amount` のいずれか一方のみを指定し、両方を同時に定義しないようにしてください。

<Tabs>
  <Tab title="ブループリント">
    <Frame>
      <img src="https://mintcdn.com/sequence-0fb8d9e6-api_docs/auazpVRK2iFuGS6h/images/unreal/get_swap_quote.png?fit=max&auto=format&n=auazpVRK2iFuGS6h&q=85&s=82c3bf7c9ae7adf08cc8fe35110db8e9" width="2182" height="1224" data-path="images/unreal/get_swap_quote.png" />
    </Frame>
  </Tab>

  <Tab title="C++">
    ```cpp theme={null}
    const TSuccessCallback<FSeqSwapQuote> OnApiSuccess = [this, OnSuccess](const FSeqSwapQuote& Response) { };
    const FFailureCallback OnApiFailure = [this, OnFailure](const FSequenceError& Error) { };

    USequencePay* Pay = NewObject<USequencePay>();
    Pay->GetSwapQuote(SequenceSdk::GetChainId(), WalletAddress, BuyCurrency, SellCurrency, BuyAmount, SellAmount, IncludeApprove, OnApiSuccess, OnApiFailure);
    ```
  </Tab>
</Tabs>

## サポートされているスワップチェーンを取得する

スワップに対応しているチェーンの一覧を返します。

<Tabs>
  <Tab title="ブループリント">
    <Frame>
      <img src="https://mintcdn.com/sequence-0fb8d9e6-api_docs/uFPNPaUQoWqBdCiH/images/unreal/supported_swap_chains.png?fit=max&auto=format&n=uFPNPaUQoWqBdCiH&q=85&s=41bcbee552001428a844378c5026c3f8" width="1726" height="930" data-path="images/unreal/supported_swap_chains.png" />
    </Frame>
  </Tab>

  <Tab title="C++">
    ```cpp theme={null}
    const TSuccessCallback<FSeqGetLifiChainsResponse> OnApiSuccess = [this, OnSuccess](const FSeqGetLifiChainsResponse& Response) { };
    const FFailureCallback OnApiFailure = [this, OnFailure](const FSequenceError& Error) { };

    USequencePay* Pay = NewObject<USequencePay>();
    Pay->GetSupportedSwapChains(OnApiSuccess, OnApiFailure);
    ```
  </Tab>
</Tabs>

## サポートされているスワップトークンを取得する

スワップに対応しているトークンの一覧を返します。

<Tabs>
  <Tab title="ブループリント">
    <Frame>
      <img src="https://mintcdn.com/sequence-0fb8d9e6-api_docs/uFPNPaUQoWqBdCiH/images/unreal/supported_swap_tokens.png?fit=max&auto=format&n=uFPNPaUQoWqBdCiH&q=85&s=ad89fab7e450950f1a4fdaed24dc09a1" width="1726" height="930" data-path="images/unreal/supported_swap_tokens.png" />
    </Frame>
  </Tab>

  <Tab title="C++">
    ```cpp theme={null}
    const TSuccessCallback<FSeqGetLifiTokensResponse> OnApiSuccess = [this, OnSuccess](const FSeqGetLifiTokensResponse& Response) { };
    const FFailureCallback OnApiFailure = [this, OnFailure](const FSequenceError& Error) { };

    USequencePay* Pay = NewObject<USequencePay>();
    Pay->GetSupportedSwapTokens(Args, OnApiSuccess, OnApiFailure);
    ```
  </Tab>
</Tabs>
